package com.nicolas.pattern.factory;

/**
 * 工厂类
 * @author nicolas 2017-02-11
 *
 */
public class SendFactory {
	
	/**
	 * 普通工厂模式
	 * @param type
	 * @return
	 */
	public Sender produce(String type) {  
        if ("mail".equals(type)) {  
            return new MailSender();  
        } else if ("sms".equals(type)) {  
            return new SmsSender();  
        } else {  
            System.out.println("请输入正确的类型!");  
            return null;  
        }  
    }
	
	/**
	 * 多个工厂方法
	 * @return
	 */
	public Sender produceMail(){  
        return new MailSender();  
    }  
      
    public Sender produceSms(){  
        return new SmsSender();  
    }  
    
    /**
     * 静态工厂方法
     * @return
     */
	public static Sender produceStaticMail(){  
        return new MailSender();  
    }  
      
    public static Sender produceStaticSms(){  
        return new SmsSender();  
    }  
}
